/* QtLua -- Lua bindings for Qt
   Copyright (C) 2011, Jarek Pelczar

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 3 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General
   Public License along with this library; if not, write to the
   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301 USA

*/

#include "qluabreakpointdata_p.h"
#include <QSharedData>

class QLuaBreakpointDataData : public QSharedData {
public:
    qint64 id;
    qint64 scriptId;
    QString fileName;
    int line;
    bool enabled;
    bool singleShot;
    int ignoreCount;
    int hitCount;
    QVariant data;

    QLuaBreakpointDataData()
        : id(-1), scriptId(-1), line(-1), enabled(false), singleShot(false),
          ignoreCount(0), hitCount(0)
    {
    }
};

QLuaBreakpointData::QLuaBreakpointData()
{
}

QLuaBreakpointData::QLuaBreakpointData(const QLuaBreakpointData &rhs) : d(rhs.d)
{
}

QLuaBreakpointData &QLuaBreakpointData::operator=(const QLuaBreakpointData &rhs)
{
    if (this != &rhs)
        d.operator=(rhs.d);
    return *this;
}

QLuaBreakpointData::~QLuaBreakpointData()
{
}

bool QLuaBreakpointData::isValid() const
{
    return d && d->scriptId != -1 && d->line != -1;
}

qint64 QLuaBreakpointData::id() const
{
    return d ? d->id : -1;
}

void QLuaBreakpointData::setId(qint64 id)
{
    if(!d)
        d = new QLuaBreakpointDataData;
    d->id = id;
}

qint64 QLuaBreakpointData::scriptId() const
{
    return d ? d->scriptId : -1;
}

void QLuaBreakpointData::setScriptId(qint64 id)
{
    if(!d)
        d = new QLuaBreakpointDataData;
    d->scriptId = id;
}


QString QLuaBreakpointData::fileName() const
{
    return d ? d->fileName : QString();
}

void QLuaBreakpointData::setFileName(QString name)
{
    if(!d)
        d = new QLuaBreakpointDataData;
    d->fileName = name;
}

int QLuaBreakpointData::lineNumber() const
{
    return d ? d->line : -1;
}

void QLuaBreakpointData::setLineNumber(int line)
{
    if(!d)
        d = new QLuaBreakpointDataData;
    d->line = line;
}

bool QLuaBreakpointData::isEnabled() const
{
    return d ? d->enabled : false;
}

void QLuaBreakpointData::setEnabled(bool en)
{
    if(!d)
        d = new QLuaBreakpointDataData;
    d->enabled = en;
}

bool QLuaBreakpointData::isSingleShot() const
{
    return d ? d->singleShot : false;
}

void QLuaBreakpointData::setSingleShot(bool singleShot)
{
    if(!d)
        d = new QLuaBreakpointDataData;
    d->singleShot = singleShot;
}

int QLuaBreakpointData::ignoreCount() const
{
    return d ? d->ignoreCount : 0;
}

void QLuaBreakpointData::setIgnoreCount(int count)
{
    if(!d)
        d = new QLuaBreakpointDataData;
    d->ignoreCount = count;
}

QVariant QLuaBreakpointData::data() const
{
    return d ? d->data : QVariant();
}

void QLuaBreakpointData::setData(QVariant data)
{
    if(!d)
        d = new QLuaBreakpointDataData;
    d->data = data;
}

int QLuaBreakpointData::hitCount() const
{
    return d ? d->hitCount : 0;
}
